package com.jt.provider.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 服务提供方的controller对象
 */
@RestController
public class ProviderController {

    /**
     * 基于@value注解告诉springboot,读取配置文件(bootstrap.yml)中
     * 的server.port的值,假如读取不到给一个默认的值8080
     */
    @Value("${server.port:8080}")
    private String server;

    //http://localhost:port/provider/echo/aaa
    @GetMapping("/provider/echo/{msg}")
    public String doRestEcho1(@PathVariable("msg") String msg){
       // return server + "say hello" + msg;

        //return server.concat(" say hello ").concat(msg);

        return String.format("%s say hello %s",server,msg);
    }
}
